﻿<?php
    session_start();
    if(!file_exists('baiduwy'))mkdir('baiduwy');
    $gjc = $_GET['word'];
    if(strlen($gjc) <= 0){
        $gjc = $_SESSION['Xdjgjc'];
    }else{
        header("Content-type: text/html; charset=utf-8");
    }
    if(strlen($gjc) <= 0){
        $gjc = '百度今日数据';
    }
    $ch = curl_init();
 // 2. 设置选项，包括URL
     curl_setopt($ch,CURLOPT_URL,"http://m.baidu.com/s?word={$gjc}");
     curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
     curl_setopt($ch,CURLOPT_HEADER,0);
     // 3. 执行并获取HTML文档内容
     $output = curl_exec($ch);
     if(!$output === FALSE ){
        file_put_contents("baiduwy/" . iconv('utf-8', 'gbk//IGNORE',$gjc).".htm",$output);
     }
     // 4. 释放curl句柄
     curl_close($ch);
?>